import Vue from 'vue'
import VueRouter, { NavigationGuardNext, Route, RouteConfig } from 'vue-router'

Vue.use(VueRouter)

export const routes = [
  {
    path: '/',
    redirect: '/my'
  },
  {
    path: '/my',
    component: () => import('../views/index.vue'),
    children: [
      {
        path: '/',
        redirect: 'index'
      },
      {
        path: 'index',
        name: 'index',
        meta: {
          pageName: '每日素材'
        },
        component: () => import('../views/mod/DailyOf.vue')
      },
      {
        path: 'ck',
        name: 'ck',
        meta: {
          pageName: 'cookie页面'
        },
        component: () => import('../views/mod/CookieOf.vue')
      },
      {
        path: 'time',
        name: 'time',
        meta: {
          pageName: '时间页面'
        },
        component: () => import('../views/mod/TimeOf.vue')
      },
      {
        path: 'risk',
        name: 'risk',
        meta: {
          pageName: '任务页面'
        },
        component: () => import('../views/mod/RiskOf.vue')
      },
    ]
  },
  {
    path: '/cart',
    name: 'cart',
    meta: {
      pageName: '跑跑卡丁车页面'
    },
    component: () => import('../views/cart.vue')
  }
]

const router = new VueRouter({
  routes,
})
router.beforeEach((to, from, next) => {
  document.title = to.meta.pageName
  next()
})

export default router
